package com.zyf.service;

import com.zyf.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserService {
    private User user;

    @Autowired
    public UserService(User user) {
        this.user = user;
    }

    public User getUser() {
        return user;
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("SpringConfig.xml");
        UserService userService = context.getBean(UserService.class);
        System.out.println("User: " + userService.getUser().getName());
    }
}